// 获取校区信息
import { SchoolType } from '../types/dapao-school'
import request from '../utils/request'
interface SearchType {
    [key: string]: string | {}
}



// 新增校区
export const SchoolPost = (obj:SchoolType) => {
    return request.post('classes/school', obj)
}
// 修改校区
export const SchoolUpdate = (id:string,obj:SchoolType) => {
    return request.put('classes/school/'+id, obj)
}


// 获取校区
export const SchoolGet = (page: number = 1, limit: number = 5, search = {} as SearchType) => {
    for (let i in search) {
        if (search[i] == '') {
            delete search[i];
        }
    }
    if (search.schoolName) {
        search.schoolName = { "$regex": `${search.schoolName}`, "$options": "i" }

        console.log(search.schoolName);
    }
    let skip = (page - 1) * limit
    return request.get('classes/school', {
        params: {
            limit,
            count: 1,
            skip,
            where: search
        }
    })
}